<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script>
			function show(){
				// 1.创建异步对象
				var xhr=new XMLHttpRequest();
				//4.接收响应,开启监听
			xhr.onreadystatechange=function(){
				if(xhr.readyState==4 && xhr.status==200){
					var r=xhr.responseText;
					console.log(r);
				}
			}
				//console.log(xhr);
				//2.创建请求,打开连接
				xhr.open("get","http://127.0.0.1:8080/ajax/first",true);
				//3.发送请求,参数如果是查询字符串,可以用null,可以不填,如果是请求主体, xhr.send(formdata);
				xhr.send(null);
				
				
			}
		</script>
	</head>
	<body>
		<button onclick="show()">显示</button>
		<div id="d1"></div>
	</body>
</html>
